package sb.simple.swagger;

import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("swaggerA")
@Api(value = "分组A=若未定义tags则value值用作于分组，一般设为api path=>/swaggerA", tags = "分组A", description = "详细描述但已废弃")
public class SwaggerAController {

    @GetMapping("hello")
    //httpMethod可选值=>"GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"
    //code=>默认200
    @ApiOperation(value = "简要说明", notes = "详细说明", httpMethod = "GET", code = 200)
    @ApiImplicitParams({//对单一参数进行注解
            //@ApiImplicitParam(name = "参数名称", value = "参数说明", required = true, dataType = "参数类型=>String, int, boolean, 类名等", paramType = "参数的请求类型=>path, query, body, header, form"),
            @ApiImplicitParam(name = "name", value = "名字", required = true, dataType = "String", paramType = "query")
    })
    @ApiResponses({//描述可能返回的结果
            @ApiResponse(code = 200, message = "易于理解的描述", response = String.class, responseContainer = "返回的容器类型=>List, Set, Map其他值会被忽略"),
    })
    public String hello(String name) {
        return "hello:" + name;
    }

    @PostMapping("hi")
    //@ApiParam对参数进行简短的说明
    public String hi(/*@ApiParam(value = "姓名", required = true) */String username) {
        return "hi:" + username;
    }
}
